<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1">
	<title>计划1</title>
	<link rel="stylesheet" href="../vender/css/normalize.css">
	<link rel="stylesheet" href="plan_1.css">
	<link rel="stylesheet" href="../public_css/public_header.css">
	<link rel="stylesheet" href="../public/public_footer.css">
</head>
<body>
<header class=".public_header">
	<p>我的教学计划</p>
	<!--<span>消息</span>-->
</header>
<section>
	<div class="practice_time">
		<div class="which_day">
			<span class="which_day_active" name="hide_field1">今天</span>
			<span name="hide_field2">明天</span>
			<span name="hide_field3">后天</span>
		</div>
	</div>
	<div class="time_frame hide_field1">
		<ul class="time_frame_ul_1" id="today">
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>07:00~08:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today" id="checkbox_c1" value="1" checked  class="chk_3"/><label for="checkbox_c1"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>08:20~09:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today"  id="checkbox_c2" value="2" checked  class="chk_3" /><label for="checkbox_c2"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>09:40~10:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today"  id="checkbox_c3" value="3"  checked  class="chk_3" /><label for="checkbox_c3"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>11:00~12:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today"  id="checkbox_c4" value="4"  checked  class="chk_3" /><label for="checkbox_c4"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>12:20~13:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today"  id="checkbox_c5" checked  value="5"  class="chk_3" /><label for="checkbox_c5"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>13:40~14:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today"  id="checkbox_c6" checked  value="6"  class="chk_3" /><label for="checkbox_c6"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>15:00~16:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today"  id="checkbox_c7" checked  value="7"  class="chk_3" /><label for="checkbox_c7"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>16:20~17:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today"  id="checkbox_c8" checked  value="8"  class="chk_3" /><label for="checkbox_c8"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>17:40~18:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="today"  id="checkbox_c9" checked  value="9"  class="chk_3" /><label for="checkbox_c9"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
		</ul>
	</div>

	<div class="time_frame hide_field2">
		<ul class="time_frame_ul_1" id="tomorrow">
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>07:00~08:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="tomorrow" value="1"  id="checkbox_b1" checked class="chk_3" /><label for="checkbox_b1"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>08:20~09:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="tomorrow"  value="2"  id="checkbox_b2" checked class="chk_3" /><label for="checkbox_b2"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>09:40~10:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox"  name="tomorrow"  value="3" id="checkbox_b3"  checked class="chk_3" /><label for="checkbox_b3"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>11:00~12:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox"  name="tomorrow" value="4"  id="checkbox_b4" checked  class="chk_3" /><label for="checkbox_b4"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>12:20~13:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="tomorrow"  value="5"  id="checkbox_b5"  checked class="chk_3" /><label for="checkbox_b5"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>13:40~14:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox"  name="tomorrow" value="6"  id="checkbox_b6" checked  class="chk_3" /><label for="checkbox_b6"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>15:00~16:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox"  name="tomorrow" value="7"  id="checkbox_b7" checked  class="chk_3" /><label for="checkbox_b7"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>16:20~17:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="tomorrow"  value="8"  id="checkbox_b8" checked  class="chk_3" /><label for="checkbox_b8"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>17:40~18:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="tomorrow"  value="9"  id="checkbox_b9" checked  class="chk_3" /><label for="checkbox_b9"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
		</ul>
	</div>

	<div class="time_frame hide_field3">
		<ul class="time_frame_ul_1"  id="after">
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>07:00~08:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="after" value="1"   id="checkbox_a1" checked  class="chk_3" /><label for="checkbox_a1"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>08:20~09:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="after"  value="2"  id="checkbox_a2"  checked class="chk_3" /><label for="checkbox_a2"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>09:40~10:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox"  name="after"  value="3" id="checkbox_a3" checked  class="chk_3" /><label for="checkbox_a3"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>11:00~12:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="after"  value="4"  id="checkbox_a4" checked  class="chk_3" /><label for="checkbox_a4"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>12:20~13:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="after"  value="5"  id="checkbox_a5" checked  class="chk_3" /><label for="checkbox_a5"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>13:40~14:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="after" value="6"   id="checkbox_a6"  checked class="chk_3" /><label for="checkbox_a6"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>15:00~16:00</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="after"  value="7"  id="checkbox_a7" checked  class="chk_3" /><label for="checkbox_a7"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>16:20~17:20</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="after"  value="8"  id="checkbox_a8" checked  class="chk_3" /><label for="checkbox_a8"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
			<li class="time_frame_ul_li">
				<ul class="time_frame_ul_2">
					<li>17:40~18:40</li>
					<li class="a">暂无</li>
					<li>
						<form>
							<label>
								<input type="checkbox" name="after"  value="9" id="checkbox_a9" checked  class="chk_3" /><label for="checkbox_a9"></label>
							</label>
						</form>
					</li>
				</ul>
			</li>
		</ul>
	</div>
	<div class="time_frame_ul_li submit-final1">
		<button class="submit-final">提交</button>
	</div>
</section>
<footer id="public_footer">
	<ul class="footer_list">
		<li class="order"  onclick="window.location.href='../order/oder.html'">
			<img src="../img/footer_list.png" alt="">
		</li>
		<li>
			<img src="../img/footer_plan_on.png" alt="">
		</li>
		<li onclick="window.location.href='../cash/cash.html'">
			<img src="../img/footer_cash.png" alt="">
		</li>
		<li  onclick="window.location.href='../coach-I/coach-me.html'">
			<img src="../img/footer_me.png" alt="">
		</li>
	</ul>
</footer>
<script src="http://www.heibaipig.com/front/js/jquery-1.11.0.min.js"></script>
<script src="../vender/src/picturefill.js"></script>
<script src="index1.js"></script>
<script src="../layer.js"></script>
<script type="text/javascript">
	function sta(){
		var mydate = new Date();
		var h =mydate.getHours();
		var m=mydate.getMinutes();
		var time=h+m/60;
		if(time>=7 && time<8.33){
			$('#today input').eq(0).prop('disabled',true);
		}
		else if(time>=8.33 && time<=9.66){
			for(var i=0;i<2;i++){
				$('#today input').eq(i).prop('disabled',true);
			}
		}
		else if(time>=9.66 && time<=11){
			for(var i=0;i<3;i++){
				$('#today input').eq(i).prop('disabled',true);
			}
		}
		else if(time>=11 && time<=12.33){
			for(var i=0;i<4;i++){
				$('#today input').eq(i).prop('disabled',true);
			}
		}
		else if(time>=12.33 && time<=13.66){
			for(var i=0;i<5;i++){
				$('#today input').eq(i).prop('disabled',true);
			}
		}
		else if(time>=13.66 && time<=15){
			for(var i=0;i<6;i++){
				$('#today input').eq(i).prop('disabled',true);
			}
		}
		else if(time>=15 && time<=16.33){
			for(var i=0;i<7;i++){
				$('#today input').eq(i).prop('disabled',true);
			}
		}
		else if(time>=16.33 && time<=17.66){
			for(var i=0;i<8;i++){
				$('#today input').eq(i).prop('disabled',true);
			}
		}
		else if(time>=17.66){
			for(var i=0;i<9;i++){
				$('#today input').eq(i).prop('disabled',true);
			}
		}
	}
	$(function () {
		sta();
		setInterval(function () {
			sta();
		},30000);

		var token = localStorage.phone;
		$.ajax({
			url: "https://newapp.icandrive.cn/api/teacher_time.php",
			type: 'post',
			data: {token: token},
			dataType: 'json',
			success: function (data) {
				if(data.status==200){
                    var start=new Date();
        start.setHours(0);
        start.setMinutes(0);
        start.setSeconds(0);
        start.setMilliseconds(0);
        var str=Date.parse(start)/1000;


					$(data.time).each(function(){


						if(this.clear_date){
							var timestamp = Date.parse(this.clear_date)/1000;
							var data=(timestamp-str)/3600/24;
							this.time_id=this.time_id-1;

							if(data>0 && data<1){//代表今天
								$('#today input').eq(this.time_id).prop('checked',false);
							}
							if(data>=1 && data<2){//代表明天
								$('#tomorrow input').eq(this.time_id).prop('checked',false);
							}
							if(data>=2 && data<3){//代表后天
								$('#after input').eq(this.time_id).prop('checked',false);
							}
						}else{
							var timestamp = Date.parse(this.order_time)/1000;
							var date=(timestamp-str)/3600/24;
							var data=Math.ceil(date);
							this.time_id=parseInt(this.time_id)-1;
							if(data==0){//代表今天
								$('#today .a').eq(this.time_id).html("<span style='color: orangered'>"+this.user_name+"</span>");
								$('#today input').eq(this.time_id).prop('disabled',true);
							}
							if(data==1){//代表明天
								$('#tomorrow .a').eq(this.time_id).html("<span style='color: orangered'>"+this.user_name+"</span>");
								$('#tomorrow input').eq(this.time_id).prop('disabled',true);
							}
							if(data==2){//代表后天
								$('#after .a').eq(this.time_id).html("<span style='color: orangered'>"+this.user_name+"</span>");
								$('#after input').eq(this.time_id).prop('disabled',true);
							}
						}


					});



								var token = localStorage.phone;
		var today = $('input:checkbox[name=today]:checked');
		var tomorrow = $('input:checkbox[name=tomorrow]:checked');
		var after = $('input:checkbox[name=after]:checked');
		var untoday = $("input[name='today']").not("input:checked");
		var untomorrow = $("input[name='tomorrow']").not("input:checked");
		var unafter = $("input[name='after']").not("input:checked");
		$(".submit-final").click(function(){
			//获取今天设置的时间
			var todayArr=[];
			$(today).each(function () {
				if(!$(this).prop('checked')){
					todayArr.push($(this).val())
				}
			});
			//获取明天设置的时间
			var tomorrowArr=[];
			$(tomorrow).each(function () {
				if(!$(this).prop('checked')){
					tomorrowArr.push($(this).val())
				}
			});
			//获取后天设置的时间
			var afterArr=[];
			$(after).each(function () {
				if(!$(this).prop('checked')){
					afterArr.push($(this).val())
				}
			});

			//获取今天开启时间
			var untodayArr=[];
			$(untoday).each(function () {
				if($(this).prop('checked')){
					untodayArr.push($(this).val());
				}
			});
			//获取明天开启时间
			var untomorrowArr=[];
			$(untomorrow).each(function () {
				if($(this).prop('checked')){
					untomorrowArr.push($(this).val());
				}
			})
			//获取后天开启时间
			var unafterArr=[];
			$(unafter).each(function () {
				if($(this).prop('checked')){
					unafterArr.push($(this).val());
				}
			});

			$.ajax({
				url: "https://newapp.icandrive.cn/api/saveplan.php",
				type: 'post',
				data: {token: token,today:todayArr,tomorrow:tomorrowArr,after:afterArr,ctoday:untodayArr,ctomorrow:untomorrowArr,cafter:unafterArr},
				dataType: 'json',
				success: function (data) {
					console.log(data);
					if(data.status==200){
						layer.msg('修改成功');
						setInterval(function () {
							history.go(0);
						},2000);

					}else if(data.status==401){
						layer.msg('修改失败，已有学员下单');
						setInterval(function () {
							history.go(0);
						},2000);
					}else{
						layer.msg('修改失败');
					}
				},
				error: function () {
					 layer.msg('系统维护中',function(){
                                history.go(0)
                            },1000);
				}
			});
		});
				}
				if(data.status==250){
					layer.msg("请重新登录");
					setInterval(function(){
						window.location.href="../login/log_in.html";
					},2000)
				}
			},
			error: function () {
				 layer.msg('系统维护中',function(){
                                history.go(0)
                            },1000);
			}
		});
	});










</script>




       <script>
    document.addEventListener("plusready", function() {
        // 注册返回按键事件
        plus.key.addEventListener('backbutton', function() {
        // 事件处理
            plus.nativeUI.confirm("退出程序？", function(event) {
                if (event.index) {
                    plus.runtime.quit();
                }
            }, null, ["取消", "确定"]);
        }, false);
    });

    </script>
</body>
</html>
